package com.xjgzinfo.usdp.web.rest;

import com.xjgzinfo.usdp.AvueServer4jApp;
import com.xjgzinfo.usdp.config.TestSecurityConfiguration;
import com.xjgzinfo.usdp.domain.LowcodeMarket;
import com.xjgzinfo.usdp.repository.LowcodeMarketRepository;
import com.xjgzinfo.usdp.service.LowcodeMarketService;
import com.xjgzinfo.usdp.service.dto.LowcodeMarketDTO;
import com.xjgzinfo.usdp.service.mapper.LowcodeMarketMapper;
import com.xjgzinfo.usdp.service.dto.LowcodeMarketCriteria;
import com.xjgzinfo.usdp.service.LowcodeMarketQueryService;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

/**
 * Integration tests for the {@link LowcodeMarketResource} REST controller.
 */
@SpringBootTest(classes = { AvueServer4jApp.class, TestSecurityConfiguration.class })
@AutoConfigureMockMvc
@WithMockUser
public class LowcodeMarketResourceIT {

    private static final String DEFAULT_NAME = "AAAAAAAAAA";
    private static final String UPDATED_NAME = "BBBBBBBBBB";

    private static final String DEFAULT_TYPE = "AAAAAAAAAA";
    private static final String UPDATED_TYPE = "BBBBBBBBBB";

    private static final String DEFAULT_CREATE_USER = "AAAAAAAAAA";
    private static final String UPDATED_CREATE_USER = "BBBBBBBBBB";

    private static final Instant DEFAULT_CREATE_TIME = Instant.ofEpochMilli(0L);
    private static final Instant UPDATED_CREATE_TIME = Instant.now().truncatedTo(ChronoUnit.MILLIS);

    private static final String DEFAULT_ICON_URL = "AAAAAAAAAA";
    private static final String UPDATED_ICON_URL = "BBBBBBBBBB";

    private static final Boolean DEFAULT_ENABLE = false;
    private static final Boolean UPDATED_ENABLE = true;

    private static final String DEFAULT_RESOURCE_ID = "AAAAAAAAAA";
    private static final String UPDATED_RESOURCE_ID = "BBBBBBBBBB";

    private static final String DEFAULT_RESOURCE_URL = "AAAAAAAAAA";
    private static final String UPDATED_RESOURCE_URL = "BBBBBBBBBB";

    private static final String DEFAULT_DEMO_URL = "AAAAAAAAAA";
    private static final String UPDATED_DEMO_URL = "BBBBBBBBBB";

    private static final Boolean DEFAULT_ENABLED = false;
    private static final Boolean UPDATED_ENABLED = true;

    @Autowired
    private LowcodeMarketRepository lowcodeMarketRepository;

    @Autowired
    private LowcodeMarketMapper lowcodeMarketMapper;

    @Autowired
    private LowcodeMarketService lowcodeMarketService;

    @Autowired
    private LowcodeMarketQueryService lowcodeMarketQueryService;

    @Autowired
    private EntityManager em;

    @Autowired
    private MockMvc restLowcodeMarketMockMvc;

    private LowcodeMarket lowcodeMarket;

    /**
     * Create an entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static LowcodeMarket createEntity(EntityManager em) {
        LowcodeMarket lowcodeMarket = new LowcodeMarket()
            .name(DEFAULT_NAME)
            .type(DEFAULT_TYPE)
            .createUser(DEFAULT_CREATE_USER)
            .createTime(DEFAULT_CREATE_TIME)
            .iconUrl(DEFAULT_ICON_URL)
            .enable(DEFAULT_ENABLE)
            .resourceId(DEFAULT_RESOURCE_ID)
            .resourceUrl(DEFAULT_RESOURCE_URL)
            .demoUrl(DEFAULT_DEMO_URL)
            .enabled(DEFAULT_ENABLED);
        return lowcodeMarket;
    }
    /**
     * Create an updated entity for this test.
     *
     * This is a static method, as tests for other entities might also need it,
     * if they test an entity which requires the current entity.
     */
    public static LowcodeMarket createUpdatedEntity(EntityManager em) {
        LowcodeMarket lowcodeMarket = new LowcodeMarket()
            .name(UPDATED_NAME)
            .type(UPDATED_TYPE)
            .createUser(UPDATED_CREATE_USER)
            .createTime(UPDATED_CREATE_TIME)
            .iconUrl(UPDATED_ICON_URL)
            .enable(UPDATED_ENABLE)
            .resourceId(UPDATED_RESOURCE_ID)
            .resourceUrl(UPDATED_RESOURCE_URL)
            .demoUrl(UPDATED_DEMO_URL)
            .enabled(UPDATED_ENABLED);
        return lowcodeMarket;
    }

    @BeforeEach
    public void initTest() {
        lowcodeMarket = createEntity(em);
    }

    @Test
    @Transactional
    public void createLowcodeMarket() throws Exception {
        int databaseSizeBeforeCreate = lowcodeMarketRepository.findAll().size();
        // Create the LowcodeMarket
        LowcodeMarketDTO lowcodeMarketDTO = lowcodeMarketMapper.toDto(lowcodeMarket);
        restLowcodeMarketMockMvc.perform(post("/api/lowcode-markets").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(lowcodeMarketDTO)))
            .andExpect(status().isCreated());

        // Validate the LowcodeMarket in the database
        List<LowcodeMarket> lowcodeMarketList = lowcodeMarketRepository.findAll();
        assertThat(lowcodeMarketList).hasSize(databaseSizeBeforeCreate + 1);
        LowcodeMarket testLowcodeMarket = lowcodeMarketList.get(lowcodeMarketList.size() - 1);
        assertThat(testLowcodeMarket.getName()).isEqualTo(DEFAULT_NAME);
        assertThat(testLowcodeMarket.getType()).isEqualTo(DEFAULT_TYPE);
        assertThat(testLowcodeMarket.getCreateUser()).isEqualTo(DEFAULT_CREATE_USER);
        assertThat(testLowcodeMarket.getCreateTime()).isEqualTo(DEFAULT_CREATE_TIME);
        assertThat(testLowcodeMarket.getIconUrl()).isEqualTo(DEFAULT_ICON_URL);
        assertThat(testLowcodeMarket.isEnable()).isEqualTo(DEFAULT_ENABLE);
        assertThat(testLowcodeMarket.getResourceId()).isEqualTo(DEFAULT_RESOURCE_ID);
        assertThat(testLowcodeMarket.getResourceUrl()).isEqualTo(DEFAULT_RESOURCE_URL);
        assertThat(testLowcodeMarket.getDemoUrl()).isEqualTo(DEFAULT_DEMO_URL);
        assertThat(testLowcodeMarket.isEnabled()).isEqualTo(DEFAULT_ENABLED);
    }

    @Test
    @Transactional
    public void createLowcodeMarketWithExistingId() throws Exception {
        int databaseSizeBeforeCreate = lowcodeMarketRepository.findAll().size();

        // Create the LowcodeMarket with an existing ID
        lowcodeMarket.setId(1L);
        LowcodeMarketDTO lowcodeMarketDTO = lowcodeMarketMapper.toDto(lowcodeMarket);

        // An entity with an existing ID cannot be created, so this API call must fail
        restLowcodeMarketMockMvc.perform(post("/api/lowcode-markets").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(lowcodeMarketDTO)))
            .andExpect(status().isBadRequest());

        // Validate the LowcodeMarket in the database
        List<LowcodeMarket> lowcodeMarketList = lowcodeMarketRepository.findAll();
        assertThat(lowcodeMarketList).hasSize(databaseSizeBeforeCreate);
    }


    @Test
    @Transactional
    public void checkNameIsRequired() throws Exception {
        int databaseSizeBeforeTest = lowcodeMarketRepository.findAll().size();
        // set the field null
        lowcodeMarket.setName(null);

        // Create the LowcodeMarket, which fails.
        LowcodeMarketDTO lowcodeMarketDTO = lowcodeMarketMapper.toDto(lowcodeMarket);


        restLowcodeMarketMockMvc.perform(post("/api/lowcode-markets").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(lowcodeMarketDTO)))
            .andExpect(status().isBadRequest());

        List<LowcodeMarket> lowcodeMarketList = lowcodeMarketRepository.findAll();
        assertThat(lowcodeMarketList).hasSize(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    public void checkTypeIsRequired() throws Exception {
        int databaseSizeBeforeTest = lowcodeMarketRepository.findAll().size();
        // set the field null
        lowcodeMarket.setType(null);

        // Create the LowcodeMarket, which fails.
        LowcodeMarketDTO lowcodeMarketDTO = lowcodeMarketMapper.toDto(lowcodeMarket);


        restLowcodeMarketMockMvc.perform(post("/api/lowcode-markets").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(lowcodeMarketDTO)))
            .andExpect(status().isBadRequest());

        List<LowcodeMarket> lowcodeMarketList = lowcodeMarketRepository.findAll();
        assertThat(lowcodeMarketList).hasSize(databaseSizeBeforeTest);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarkets() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList
        restLowcodeMarketMockMvc.perform(get("/api/lowcode-markets?sort=id,desc"))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.[*].id").value(hasItem(lowcodeMarket.getId().intValue())))
            .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME)))
            .andExpect(jsonPath("$.[*].type").value(hasItem(DEFAULT_TYPE)))
            .andExpect(jsonPath("$.[*].createUser").value(hasItem(DEFAULT_CREATE_USER)))
            .andExpect(jsonPath("$.[*].createTime").value(hasItem(DEFAULT_CREATE_TIME.toString())))
            .andExpect(jsonPath("$.[*].iconUrl").value(hasItem(DEFAULT_ICON_URL)))
            .andExpect(jsonPath("$.[*].enable").value(hasItem(DEFAULT_ENABLE.booleanValue())))
            .andExpect(jsonPath("$.[*].resourceId").value(hasItem(DEFAULT_RESOURCE_ID)))
            .andExpect(jsonPath("$.[*].resourceUrl").value(hasItem(DEFAULT_RESOURCE_URL)))
            .andExpect(jsonPath("$.[*].demoUrl").value(hasItem(DEFAULT_DEMO_URL)))
            .andExpect(jsonPath("$.[*].enabled").value(hasItem(DEFAULT_ENABLED.booleanValue())));
    }
    
    @Test
    @Transactional
    public void getLowcodeMarket() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get the lowcodeMarket
        restLowcodeMarketMockMvc.perform(get("/api/lowcode-markets/{id}", lowcodeMarket.getId()))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.id").value(lowcodeMarket.getId().intValue()))
            .andExpect(jsonPath("$.name").value(DEFAULT_NAME))
            .andExpect(jsonPath("$.type").value(DEFAULT_TYPE))
            .andExpect(jsonPath("$.createUser").value(DEFAULT_CREATE_USER))
            .andExpect(jsonPath("$.createTime").value(DEFAULT_CREATE_TIME.toString()))
            .andExpect(jsonPath("$.iconUrl").value(DEFAULT_ICON_URL))
            .andExpect(jsonPath("$.enable").value(DEFAULT_ENABLE.booleanValue()))
            .andExpect(jsonPath("$.resourceId").value(DEFAULT_RESOURCE_ID))
            .andExpect(jsonPath("$.resourceUrl").value(DEFAULT_RESOURCE_URL))
            .andExpect(jsonPath("$.demoUrl").value(DEFAULT_DEMO_URL))
            .andExpect(jsonPath("$.enabled").value(DEFAULT_ENABLED.booleanValue()));
    }


    @Test
    @Transactional
    public void getLowcodeMarketsByIdFiltering() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        Long id = lowcodeMarket.getId();

        defaultLowcodeMarketShouldBeFound("id.equals=" + id);
        defaultLowcodeMarketShouldNotBeFound("id.notEquals=" + id);

        defaultLowcodeMarketShouldBeFound("id.greaterThanOrEqual=" + id);
        defaultLowcodeMarketShouldNotBeFound("id.greaterThan=" + id);

        defaultLowcodeMarketShouldBeFound("id.lessThanOrEqual=" + id);
        defaultLowcodeMarketShouldNotBeFound("id.lessThan=" + id);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByNameIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where name equals to DEFAULT_NAME
        defaultLowcodeMarketShouldBeFound("name.equals=" + DEFAULT_NAME);

        // Get all the lowcodeMarketList where name equals to UPDATED_NAME
        defaultLowcodeMarketShouldNotBeFound("name.equals=" + UPDATED_NAME);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByNameIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where name not equals to DEFAULT_NAME
        defaultLowcodeMarketShouldNotBeFound("name.notEquals=" + DEFAULT_NAME);

        // Get all the lowcodeMarketList where name not equals to UPDATED_NAME
        defaultLowcodeMarketShouldBeFound("name.notEquals=" + UPDATED_NAME);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByNameIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where name in DEFAULT_NAME or UPDATED_NAME
        defaultLowcodeMarketShouldBeFound("name.in=" + DEFAULT_NAME + "," + UPDATED_NAME);

        // Get all the lowcodeMarketList where name equals to UPDATED_NAME
        defaultLowcodeMarketShouldNotBeFound("name.in=" + UPDATED_NAME);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByNameIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where name is not null
        defaultLowcodeMarketShouldBeFound("name.specified=true");

        // Get all the lowcodeMarketList where name is null
        defaultLowcodeMarketShouldNotBeFound("name.specified=false");
    }
                @Test
    @Transactional
    public void getAllLowcodeMarketsByNameContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where name contains DEFAULT_NAME
        defaultLowcodeMarketShouldBeFound("name.contains=" + DEFAULT_NAME);

        // Get all the lowcodeMarketList where name contains UPDATED_NAME
        defaultLowcodeMarketShouldNotBeFound("name.contains=" + UPDATED_NAME);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByNameNotContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where name does not contain DEFAULT_NAME
        defaultLowcodeMarketShouldNotBeFound("name.doesNotContain=" + DEFAULT_NAME);

        // Get all the lowcodeMarketList where name does not contain UPDATED_NAME
        defaultLowcodeMarketShouldBeFound("name.doesNotContain=" + UPDATED_NAME);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByTypeIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where type equals to DEFAULT_TYPE
        defaultLowcodeMarketShouldBeFound("type.equals=" + DEFAULT_TYPE);

        // Get all the lowcodeMarketList where type equals to UPDATED_TYPE
        defaultLowcodeMarketShouldNotBeFound("type.equals=" + UPDATED_TYPE);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByTypeIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where type not equals to DEFAULT_TYPE
        defaultLowcodeMarketShouldNotBeFound("type.notEquals=" + DEFAULT_TYPE);

        // Get all the lowcodeMarketList where type not equals to UPDATED_TYPE
        defaultLowcodeMarketShouldBeFound("type.notEquals=" + UPDATED_TYPE);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByTypeIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where type in DEFAULT_TYPE or UPDATED_TYPE
        defaultLowcodeMarketShouldBeFound("type.in=" + DEFAULT_TYPE + "," + UPDATED_TYPE);

        // Get all the lowcodeMarketList where type equals to UPDATED_TYPE
        defaultLowcodeMarketShouldNotBeFound("type.in=" + UPDATED_TYPE);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByTypeIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where type is not null
        defaultLowcodeMarketShouldBeFound("type.specified=true");

        // Get all the lowcodeMarketList where type is null
        defaultLowcodeMarketShouldNotBeFound("type.specified=false");
    }
                @Test
    @Transactional
    public void getAllLowcodeMarketsByTypeContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where type contains DEFAULT_TYPE
        defaultLowcodeMarketShouldBeFound("type.contains=" + DEFAULT_TYPE);

        // Get all the lowcodeMarketList where type contains UPDATED_TYPE
        defaultLowcodeMarketShouldNotBeFound("type.contains=" + UPDATED_TYPE);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByTypeNotContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where type does not contain DEFAULT_TYPE
        defaultLowcodeMarketShouldNotBeFound("type.doesNotContain=" + DEFAULT_TYPE);

        // Get all the lowcodeMarketList where type does not contain UPDATED_TYPE
        defaultLowcodeMarketShouldBeFound("type.doesNotContain=" + UPDATED_TYPE);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateUserIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createUser equals to DEFAULT_CREATE_USER
        defaultLowcodeMarketShouldBeFound("createUser.equals=" + DEFAULT_CREATE_USER);

        // Get all the lowcodeMarketList where createUser equals to UPDATED_CREATE_USER
        defaultLowcodeMarketShouldNotBeFound("createUser.equals=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateUserIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createUser not equals to DEFAULT_CREATE_USER
        defaultLowcodeMarketShouldNotBeFound("createUser.notEquals=" + DEFAULT_CREATE_USER);

        // Get all the lowcodeMarketList where createUser not equals to UPDATED_CREATE_USER
        defaultLowcodeMarketShouldBeFound("createUser.notEquals=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateUserIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createUser in DEFAULT_CREATE_USER or UPDATED_CREATE_USER
        defaultLowcodeMarketShouldBeFound("createUser.in=" + DEFAULT_CREATE_USER + "," + UPDATED_CREATE_USER);

        // Get all the lowcodeMarketList where createUser equals to UPDATED_CREATE_USER
        defaultLowcodeMarketShouldNotBeFound("createUser.in=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateUserIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createUser is not null
        defaultLowcodeMarketShouldBeFound("createUser.specified=true");

        // Get all the lowcodeMarketList where createUser is null
        defaultLowcodeMarketShouldNotBeFound("createUser.specified=false");
    }
                @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateUserContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createUser contains DEFAULT_CREATE_USER
        defaultLowcodeMarketShouldBeFound("createUser.contains=" + DEFAULT_CREATE_USER);

        // Get all the lowcodeMarketList where createUser contains UPDATED_CREATE_USER
        defaultLowcodeMarketShouldNotBeFound("createUser.contains=" + UPDATED_CREATE_USER);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateUserNotContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createUser does not contain DEFAULT_CREATE_USER
        defaultLowcodeMarketShouldNotBeFound("createUser.doesNotContain=" + DEFAULT_CREATE_USER);

        // Get all the lowcodeMarketList where createUser does not contain UPDATED_CREATE_USER
        defaultLowcodeMarketShouldBeFound("createUser.doesNotContain=" + UPDATED_CREATE_USER);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateTimeIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createTime equals to DEFAULT_CREATE_TIME
        defaultLowcodeMarketShouldBeFound("createTime.equals=" + DEFAULT_CREATE_TIME);

        // Get all the lowcodeMarketList where createTime equals to UPDATED_CREATE_TIME
        defaultLowcodeMarketShouldNotBeFound("createTime.equals=" + UPDATED_CREATE_TIME);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateTimeIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createTime not equals to DEFAULT_CREATE_TIME
        defaultLowcodeMarketShouldNotBeFound("createTime.notEquals=" + DEFAULT_CREATE_TIME);

        // Get all the lowcodeMarketList where createTime not equals to UPDATED_CREATE_TIME
        defaultLowcodeMarketShouldBeFound("createTime.notEquals=" + UPDATED_CREATE_TIME);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateTimeIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createTime in DEFAULT_CREATE_TIME or UPDATED_CREATE_TIME
        defaultLowcodeMarketShouldBeFound("createTime.in=" + DEFAULT_CREATE_TIME + "," + UPDATED_CREATE_TIME);

        // Get all the lowcodeMarketList where createTime equals to UPDATED_CREATE_TIME
        defaultLowcodeMarketShouldNotBeFound("createTime.in=" + UPDATED_CREATE_TIME);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByCreateTimeIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where createTime is not null
        defaultLowcodeMarketShouldBeFound("createTime.specified=true");

        // Get all the lowcodeMarketList where createTime is null
        defaultLowcodeMarketShouldNotBeFound("createTime.specified=false");
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByIconUrlIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where iconUrl equals to DEFAULT_ICON_URL
        defaultLowcodeMarketShouldBeFound("iconUrl.equals=" + DEFAULT_ICON_URL);

        // Get all the lowcodeMarketList where iconUrl equals to UPDATED_ICON_URL
        defaultLowcodeMarketShouldNotBeFound("iconUrl.equals=" + UPDATED_ICON_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByIconUrlIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where iconUrl not equals to DEFAULT_ICON_URL
        defaultLowcodeMarketShouldNotBeFound("iconUrl.notEquals=" + DEFAULT_ICON_URL);

        // Get all the lowcodeMarketList where iconUrl not equals to UPDATED_ICON_URL
        defaultLowcodeMarketShouldBeFound("iconUrl.notEquals=" + UPDATED_ICON_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByIconUrlIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where iconUrl in DEFAULT_ICON_URL or UPDATED_ICON_URL
        defaultLowcodeMarketShouldBeFound("iconUrl.in=" + DEFAULT_ICON_URL + "," + UPDATED_ICON_URL);

        // Get all the lowcodeMarketList where iconUrl equals to UPDATED_ICON_URL
        defaultLowcodeMarketShouldNotBeFound("iconUrl.in=" + UPDATED_ICON_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByIconUrlIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where iconUrl is not null
        defaultLowcodeMarketShouldBeFound("iconUrl.specified=true");

        // Get all the lowcodeMarketList where iconUrl is null
        defaultLowcodeMarketShouldNotBeFound("iconUrl.specified=false");
    }
                @Test
    @Transactional
    public void getAllLowcodeMarketsByIconUrlContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where iconUrl contains DEFAULT_ICON_URL
        defaultLowcodeMarketShouldBeFound("iconUrl.contains=" + DEFAULT_ICON_URL);

        // Get all the lowcodeMarketList where iconUrl contains UPDATED_ICON_URL
        defaultLowcodeMarketShouldNotBeFound("iconUrl.contains=" + UPDATED_ICON_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByIconUrlNotContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where iconUrl does not contain DEFAULT_ICON_URL
        defaultLowcodeMarketShouldNotBeFound("iconUrl.doesNotContain=" + DEFAULT_ICON_URL);

        // Get all the lowcodeMarketList where iconUrl does not contain UPDATED_ICON_URL
        defaultLowcodeMarketShouldBeFound("iconUrl.doesNotContain=" + UPDATED_ICON_URL);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnableIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enable equals to DEFAULT_ENABLE
        defaultLowcodeMarketShouldBeFound("enable.equals=" + DEFAULT_ENABLE);

        // Get all the lowcodeMarketList where enable equals to UPDATED_ENABLE
        defaultLowcodeMarketShouldNotBeFound("enable.equals=" + UPDATED_ENABLE);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnableIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enable not equals to DEFAULT_ENABLE
        defaultLowcodeMarketShouldNotBeFound("enable.notEquals=" + DEFAULT_ENABLE);

        // Get all the lowcodeMarketList where enable not equals to UPDATED_ENABLE
        defaultLowcodeMarketShouldBeFound("enable.notEquals=" + UPDATED_ENABLE);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnableIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enable in DEFAULT_ENABLE or UPDATED_ENABLE
        defaultLowcodeMarketShouldBeFound("enable.in=" + DEFAULT_ENABLE + "," + UPDATED_ENABLE);

        // Get all the lowcodeMarketList where enable equals to UPDATED_ENABLE
        defaultLowcodeMarketShouldNotBeFound("enable.in=" + UPDATED_ENABLE);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnableIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enable is not null
        defaultLowcodeMarketShouldBeFound("enable.specified=true");

        // Get all the lowcodeMarketList where enable is null
        defaultLowcodeMarketShouldNotBeFound("enable.specified=false");
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceIdIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceId equals to DEFAULT_RESOURCE_ID
        defaultLowcodeMarketShouldBeFound("resourceId.equals=" + DEFAULT_RESOURCE_ID);

        // Get all the lowcodeMarketList where resourceId equals to UPDATED_RESOURCE_ID
        defaultLowcodeMarketShouldNotBeFound("resourceId.equals=" + UPDATED_RESOURCE_ID);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceIdIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceId not equals to DEFAULT_RESOURCE_ID
        defaultLowcodeMarketShouldNotBeFound("resourceId.notEquals=" + DEFAULT_RESOURCE_ID);

        // Get all the lowcodeMarketList where resourceId not equals to UPDATED_RESOURCE_ID
        defaultLowcodeMarketShouldBeFound("resourceId.notEquals=" + UPDATED_RESOURCE_ID);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceIdIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceId in DEFAULT_RESOURCE_ID or UPDATED_RESOURCE_ID
        defaultLowcodeMarketShouldBeFound("resourceId.in=" + DEFAULT_RESOURCE_ID + "," + UPDATED_RESOURCE_ID);

        // Get all the lowcodeMarketList where resourceId equals to UPDATED_RESOURCE_ID
        defaultLowcodeMarketShouldNotBeFound("resourceId.in=" + UPDATED_RESOURCE_ID);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceIdIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceId is not null
        defaultLowcodeMarketShouldBeFound("resourceId.specified=true");

        // Get all the lowcodeMarketList where resourceId is null
        defaultLowcodeMarketShouldNotBeFound("resourceId.specified=false");
    }
                @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceIdContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceId contains DEFAULT_RESOURCE_ID
        defaultLowcodeMarketShouldBeFound("resourceId.contains=" + DEFAULT_RESOURCE_ID);

        // Get all the lowcodeMarketList where resourceId contains UPDATED_RESOURCE_ID
        defaultLowcodeMarketShouldNotBeFound("resourceId.contains=" + UPDATED_RESOURCE_ID);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceIdNotContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceId does not contain DEFAULT_RESOURCE_ID
        defaultLowcodeMarketShouldNotBeFound("resourceId.doesNotContain=" + DEFAULT_RESOURCE_ID);

        // Get all the lowcodeMarketList where resourceId does not contain UPDATED_RESOURCE_ID
        defaultLowcodeMarketShouldBeFound("resourceId.doesNotContain=" + UPDATED_RESOURCE_ID);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceUrlIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceUrl equals to DEFAULT_RESOURCE_URL
        defaultLowcodeMarketShouldBeFound("resourceUrl.equals=" + DEFAULT_RESOURCE_URL);

        // Get all the lowcodeMarketList where resourceUrl equals to UPDATED_RESOURCE_URL
        defaultLowcodeMarketShouldNotBeFound("resourceUrl.equals=" + UPDATED_RESOURCE_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceUrlIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceUrl not equals to DEFAULT_RESOURCE_URL
        defaultLowcodeMarketShouldNotBeFound("resourceUrl.notEquals=" + DEFAULT_RESOURCE_URL);

        // Get all the lowcodeMarketList where resourceUrl not equals to UPDATED_RESOURCE_URL
        defaultLowcodeMarketShouldBeFound("resourceUrl.notEquals=" + UPDATED_RESOURCE_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceUrlIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceUrl in DEFAULT_RESOURCE_URL or UPDATED_RESOURCE_URL
        defaultLowcodeMarketShouldBeFound("resourceUrl.in=" + DEFAULT_RESOURCE_URL + "," + UPDATED_RESOURCE_URL);

        // Get all the lowcodeMarketList where resourceUrl equals to UPDATED_RESOURCE_URL
        defaultLowcodeMarketShouldNotBeFound("resourceUrl.in=" + UPDATED_RESOURCE_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceUrlIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceUrl is not null
        defaultLowcodeMarketShouldBeFound("resourceUrl.specified=true");

        // Get all the lowcodeMarketList where resourceUrl is null
        defaultLowcodeMarketShouldNotBeFound("resourceUrl.specified=false");
    }
                @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceUrlContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceUrl contains DEFAULT_RESOURCE_URL
        defaultLowcodeMarketShouldBeFound("resourceUrl.contains=" + DEFAULT_RESOURCE_URL);

        // Get all the lowcodeMarketList where resourceUrl contains UPDATED_RESOURCE_URL
        defaultLowcodeMarketShouldNotBeFound("resourceUrl.contains=" + UPDATED_RESOURCE_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByResourceUrlNotContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where resourceUrl does not contain DEFAULT_RESOURCE_URL
        defaultLowcodeMarketShouldNotBeFound("resourceUrl.doesNotContain=" + DEFAULT_RESOURCE_URL);

        // Get all the lowcodeMarketList where resourceUrl does not contain UPDATED_RESOURCE_URL
        defaultLowcodeMarketShouldBeFound("resourceUrl.doesNotContain=" + UPDATED_RESOURCE_URL);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByDemoUrlIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where demoUrl equals to DEFAULT_DEMO_URL
        defaultLowcodeMarketShouldBeFound("demoUrl.equals=" + DEFAULT_DEMO_URL);

        // Get all the lowcodeMarketList where demoUrl equals to UPDATED_DEMO_URL
        defaultLowcodeMarketShouldNotBeFound("demoUrl.equals=" + UPDATED_DEMO_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByDemoUrlIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where demoUrl not equals to DEFAULT_DEMO_URL
        defaultLowcodeMarketShouldNotBeFound("demoUrl.notEquals=" + DEFAULT_DEMO_URL);

        // Get all the lowcodeMarketList where demoUrl not equals to UPDATED_DEMO_URL
        defaultLowcodeMarketShouldBeFound("demoUrl.notEquals=" + UPDATED_DEMO_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByDemoUrlIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where demoUrl in DEFAULT_DEMO_URL or UPDATED_DEMO_URL
        defaultLowcodeMarketShouldBeFound("demoUrl.in=" + DEFAULT_DEMO_URL + "," + UPDATED_DEMO_URL);

        // Get all the lowcodeMarketList where demoUrl equals to UPDATED_DEMO_URL
        defaultLowcodeMarketShouldNotBeFound("demoUrl.in=" + UPDATED_DEMO_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByDemoUrlIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where demoUrl is not null
        defaultLowcodeMarketShouldBeFound("demoUrl.specified=true");

        // Get all the lowcodeMarketList where demoUrl is null
        defaultLowcodeMarketShouldNotBeFound("demoUrl.specified=false");
    }
                @Test
    @Transactional
    public void getAllLowcodeMarketsByDemoUrlContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where demoUrl contains DEFAULT_DEMO_URL
        defaultLowcodeMarketShouldBeFound("demoUrl.contains=" + DEFAULT_DEMO_URL);

        // Get all the lowcodeMarketList where demoUrl contains UPDATED_DEMO_URL
        defaultLowcodeMarketShouldNotBeFound("demoUrl.contains=" + UPDATED_DEMO_URL);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByDemoUrlNotContainsSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where demoUrl does not contain DEFAULT_DEMO_URL
        defaultLowcodeMarketShouldNotBeFound("demoUrl.doesNotContain=" + DEFAULT_DEMO_URL);

        // Get all the lowcodeMarketList where demoUrl does not contain UPDATED_DEMO_URL
        defaultLowcodeMarketShouldBeFound("demoUrl.doesNotContain=" + UPDATED_DEMO_URL);
    }


    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnabledIsEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enabled equals to DEFAULT_ENABLED
        defaultLowcodeMarketShouldBeFound("enabled.equals=" + DEFAULT_ENABLED);

        // Get all the lowcodeMarketList where enabled equals to UPDATED_ENABLED
        defaultLowcodeMarketShouldNotBeFound("enabled.equals=" + UPDATED_ENABLED);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnabledIsNotEqualToSomething() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enabled not equals to DEFAULT_ENABLED
        defaultLowcodeMarketShouldNotBeFound("enabled.notEquals=" + DEFAULT_ENABLED);

        // Get all the lowcodeMarketList where enabled not equals to UPDATED_ENABLED
        defaultLowcodeMarketShouldBeFound("enabled.notEquals=" + UPDATED_ENABLED);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnabledIsInShouldWork() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enabled in DEFAULT_ENABLED or UPDATED_ENABLED
        defaultLowcodeMarketShouldBeFound("enabled.in=" + DEFAULT_ENABLED + "," + UPDATED_ENABLED);

        // Get all the lowcodeMarketList where enabled equals to UPDATED_ENABLED
        defaultLowcodeMarketShouldNotBeFound("enabled.in=" + UPDATED_ENABLED);
    }

    @Test
    @Transactional
    public void getAllLowcodeMarketsByEnabledIsNullOrNotNull() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        // Get all the lowcodeMarketList where enabled is not null
        defaultLowcodeMarketShouldBeFound("enabled.specified=true");

        // Get all the lowcodeMarketList where enabled is null
        defaultLowcodeMarketShouldNotBeFound("enabled.specified=false");
    }
    /**
     * Executes the search, and checks that the default entity is returned.
     */
    private void defaultLowcodeMarketShouldBeFound(String filter) throws Exception {
        restLowcodeMarketMockMvc.perform(get("/api/lowcode-markets?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.[*].id").value(hasItem(lowcodeMarket.getId().intValue())))
            .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME)))
            .andExpect(jsonPath("$.[*].type").value(hasItem(DEFAULT_TYPE)))
            .andExpect(jsonPath("$.[*].createUser").value(hasItem(DEFAULT_CREATE_USER)))
            .andExpect(jsonPath("$.[*].createTime").value(hasItem(DEFAULT_CREATE_TIME.toString())))
            .andExpect(jsonPath("$.[*].iconUrl").value(hasItem(DEFAULT_ICON_URL)))
            .andExpect(jsonPath("$.[*].enable").value(hasItem(DEFAULT_ENABLE.booleanValue())))
            .andExpect(jsonPath("$.[*].resourceId").value(hasItem(DEFAULT_RESOURCE_ID)))
            .andExpect(jsonPath("$.[*].resourceUrl").value(hasItem(DEFAULT_RESOURCE_URL)))
            .andExpect(jsonPath("$.[*].demoUrl").value(hasItem(DEFAULT_DEMO_URL)))
            .andExpect(jsonPath("$.[*].enabled").value(hasItem(DEFAULT_ENABLED.booleanValue())));

        // Check, that the count call also returns 1
        restLowcodeMarketMockMvc.perform(get("/api/lowcode-markets/count?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(content().string("1"));
    }

    /**
     * Executes the search, and checks that the default entity is not returned.
     */
    private void defaultLowcodeMarketShouldNotBeFound(String filter) throws Exception {
        restLowcodeMarketMockMvc.perform(get("/api/lowcode-markets?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$").isArray())
            .andExpect(jsonPath("$").isEmpty());

        // Check, that the count call also returns 0
        restLowcodeMarketMockMvc.perform(get("/api/lowcode-markets/count?sort=id,desc&" + filter))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(content().string("0"));
    }

    @Test
    @Transactional
    public void getNonExistingLowcodeMarket() throws Exception {
        // Get the lowcodeMarket
        restLowcodeMarketMockMvc.perform(get("/api/lowcode-markets/{id}", Long.MAX_VALUE))
            .andExpect(status().isNotFound());
    }

    @Test
    @Transactional
    public void updateLowcodeMarket() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        int databaseSizeBeforeUpdate = lowcodeMarketRepository.findAll().size();

        // Update the lowcodeMarket
        LowcodeMarket updatedLowcodeMarket = lowcodeMarketRepository.findById(lowcodeMarket.getId()).get();
        // Disconnect from session so that the updates on updatedLowcodeMarket are not directly saved in db
        em.detach(updatedLowcodeMarket);
        updatedLowcodeMarket
            .name(UPDATED_NAME)
            .type(UPDATED_TYPE)
            .createUser(UPDATED_CREATE_USER)
            .createTime(UPDATED_CREATE_TIME)
            .iconUrl(UPDATED_ICON_URL)
            .enable(UPDATED_ENABLE)
            .resourceId(UPDATED_RESOURCE_ID)
            .resourceUrl(UPDATED_RESOURCE_URL)
            .demoUrl(UPDATED_DEMO_URL)
            .enabled(UPDATED_ENABLED);
        LowcodeMarketDTO lowcodeMarketDTO = lowcodeMarketMapper.toDto(updatedLowcodeMarket);

        restLowcodeMarketMockMvc.perform(put("/api/lowcode-markets").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(lowcodeMarketDTO)))
            .andExpect(status().isOk());

        // Validate the LowcodeMarket in the database
        List<LowcodeMarket> lowcodeMarketList = lowcodeMarketRepository.findAll();
        assertThat(lowcodeMarketList).hasSize(databaseSizeBeforeUpdate);
        LowcodeMarket testLowcodeMarket = lowcodeMarketList.get(lowcodeMarketList.size() - 1);
        assertThat(testLowcodeMarket.getName()).isEqualTo(UPDATED_NAME);
        assertThat(testLowcodeMarket.getType()).isEqualTo(UPDATED_TYPE);
        assertThat(testLowcodeMarket.getCreateUser()).isEqualTo(UPDATED_CREATE_USER);
        assertThat(testLowcodeMarket.getCreateTime()).isEqualTo(UPDATED_CREATE_TIME);
        assertThat(testLowcodeMarket.getIconUrl()).isEqualTo(UPDATED_ICON_URL);
        assertThat(testLowcodeMarket.isEnable()).isEqualTo(UPDATED_ENABLE);
        assertThat(testLowcodeMarket.getResourceId()).isEqualTo(UPDATED_RESOURCE_ID);
        assertThat(testLowcodeMarket.getResourceUrl()).isEqualTo(UPDATED_RESOURCE_URL);
        assertThat(testLowcodeMarket.getDemoUrl()).isEqualTo(UPDATED_DEMO_URL);
        assertThat(testLowcodeMarket.isEnabled()).isEqualTo(UPDATED_ENABLED);
    }

    @Test
    @Transactional
    public void updateNonExistingLowcodeMarket() throws Exception {
        int databaseSizeBeforeUpdate = lowcodeMarketRepository.findAll().size();

        // Create the LowcodeMarket
        LowcodeMarketDTO lowcodeMarketDTO = lowcodeMarketMapper.toDto(lowcodeMarket);

        // If the entity doesn't have an ID, it will throw BadRequestAlertException
        restLowcodeMarketMockMvc.perform(put("/api/lowcode-markets").with(csrf())
            .contentType(MediaType.APPLICATION_JSON)
            .content(TestUtil.convertObjectToJsonBytes(lowcodeMarketDTO)))
            .andExpect(status().isBadRequest());

        // Validate the LowcodeMarket in the database
        List<LowcodeMarket> lowcodeMarketList = lowcodeMarketRepository.findAll();
        assertThat(lowcodeMarketList).hasSize(databaseSizeBeforeUpdate);
    }

    @Test
    @Transactional
    public void deleteLowcodeMarket() throws Exception {
        // Initialize the database
        lowcodeMarketRepository.saveAndFlush(lowcodeMarket);

        int databaseSizeBeforeDelete = lowcodeMarketRepository.findAll().size();

        // Delete the lowcodeMarket
        restLowcodeMarketMockMvc.perform(delete("/api/lowcode-markets/{id}", lowcodeMarket.getId()).with(csrf())
            .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isNoContent());

        // Validate the database contains one less item
        List<LowcodeMarket> lowcodeMarketList = lowcodeMarketRepository.findAll();
        assertThat(lowcodeMarketList).hasSize(databaseSizeBeforeDelete - 1);
    }
}
